package org.elepower.controller;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.elepower.dao.InspectiontaskDetailsDao;
import org.elepower.pojo.PsInspectiontaskDetails;
import org.elepower.pojo.PsInspectiontask_main;
import org.elepower.pojo.PsInspectorDetails;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Controller
@RequestMapping("/bugSel")
public class BugSelectController {
    @Autowired
    private InspectiontaskDetailsDao inspectiontaskDetailsDao;

    @RequestMapping("/index")
    public String index() throws Exception{
        return "system/bugSelect/index";
    }

    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10")Integer limit, PsInspectiontaskDetails psInspectiontaskDetails) throws Exception{
        Map<String,Object> map = new HashMap<>();
        Page<PsInspectiontask_main> pager = PageHelper.startPage(page, limit);
        //获取缺陷数据
        List<PsInspectiontaskDetails> list = inspectiontaskDetailsDao.getlist(psInspectiontaskDetails);
        map.put("code", 0);
        map.put("msg", "");
        map.put("data", list);
        map.put("count", pager.getTotal());
        return map;
    }

    @RequestMapping("/getlistBug")
    @ResponseBody
    public Map<String,Object> getlistBug(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10")Integer limit, PsInspectiontaskDetails psInspectiontaskDetails) throws Exception{
        Map<String,Object> map = new HashMap<>();
        Page<PsInspectiontask_main> pager = PageHelper.startPage(page, limit);
        //获取缺陷数据
        List<PsInspectiontaskDetails> list = inspectiontaskDetailsDao.getlistBug(psInspectiontaskDetails);
        map.put("code", 0);
        map.put("msg", "");
        map.put("data", list);
        map.put("count", pager.getTotal());
        return map;
    }
}
